home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume2 / sun2ps / part01 next >
Encoding:
Internet Message Format  |  1991-08-07  |  19.6 KB

  1. From: boysko@l.UUCP (Glenn Boysko)
  2. Newsgroups: comp.sources.misc
  3. Subject: v02i079: sun2ps - sun rasterfile to PostScript image translator
  4. Message-ID: <8803272342.AA04240@mandrill.CES.CWRU.Edu>
  5. Date: 27 Mar 88 22:42:28 GMT
  6. Approved: allbery@ncoast.UUCP
  7.  
  8. comp.sources.misc: Volume 2, Issue 79
  9. Submitted-By: "Glenn Boysko" <boysko@l.UUCP>
  10. Archive-Name: sun2ps/part01
  11.  
  12.     Enclosed is "sun2ps" - a Sun Rasterfile to PostScript image translator
  13. that uses run length encoding.
  14.  
  15. Glenn Boysko
  16. mandrill!boysko
  17. boysko@mandrill.ces.cwru.edu
  18.  
  19. ---------------------------------- cut here -----------------------------------
  20. #!/bin/sh
  21. # This is a shell archive, meaning:
  22. # 1. Remove everything above the #!/bin/sh line.
  23. # 2. Save the resulting text in a file.
  24. # 3. Execute the file with /bin/sh (not csh) to create the files:
  25. #    Makefile
  26. #    sun2ps.c
  27. #    sun2ps.l
  28. # This archive created: Fri Mar 25 16:20:42 1988
  29. # By:    Glenn J. Boysko(Case Western Reserve University)
  30. #
  31. export PATH; PATH=/bin:$PATH
  32. echo shar: extracting "'Makefile'" '(515 characters)'
  33. if test -f 'Makefile'
  34. then
  35.     echo shar: over-writing existing file "'Makefile'"
  36. fi
  37. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  38. X#
  39. X# Makefile for Sun2ps and other utilities...
  40. X#
  41. X#    Glenn Boysko    {decvax, sun}!mandrill!boysko
  42. X#            boysko@mandrill.cwru.edu
  43. X
  44. X# Diagnostics about the amount of compression, avg run length, etc
  45. X# are not reported, by default. To view these diagnostics on stderr,
  46. X# define the flag DIAGS. Extra diagnostics about the specifics of
  47. X# raster file (num of samples, image depth, etc) can be found by 
  48. X# defining EXTRADIAGS.
  49. XDIAGFLAGS = -DDIAGS -DEXTRADIAGS
  50. X
  51. XCFLAGS = -O $(DIAGFLAGS)
  52. X
  53. Xsun2ps: sun2ps.o
  54. X    cc -o sun2ps sun2ps.o
  55. SHAR_EOF
  56. if test 515 -ne "`wc -c 'Makefile'`"
  57. then
  58.     echo shar: error transmitting "'Makefile'" '(should have been 515 characters)'
  59. fi
  60. echo shar: extracting "'sun2ps.c'" '(12873 characters)'
  61. if test -f 'sun2ps.c'
  62. then
  63.     echo shar: over-writing existing file "'sun2ps.c'"
  64. fi
  65. sed 's/^X//' << \SHAR_EOF > 'sun2ps.c'
  66. X/******************************************************************************
  67. X*                                          *
  68. X*    File:         sun2ps.c                              *
  69. X*    Author:       Glenn Boysko                          *
  70. X*    Organization: Case Western Reserve University                  *
  71. X*    EMail:          {decvax, sun}!mandrill!boysko                  *
  72. X*              boysko@mandrill.cwru.edu                      *
  73. X*    Created:      Wed Mar 23 9:25pm                          *
  74. X*    Contents:     Sun Rasterfile to PostScript image (using a run-length  *
  75. X*            encoding scheme.)                      *
  76. X*                                          *
  77. X*    (Adapted from "postimage" filter by J. R. Bammi.)              *
  78. X*                                          *
  79. X*    @(#)sun2ps.c    1.7
  80. X******************************************************************************/
  81. X
  82. X/*
  83. X * Usage:
  84. X *  sun2ps [-s sizex sizey] [-t transx transy] [-r rot] [-l] [-i] [-a] file ...
  85. X *
  86. X *    -s sizex sizey   = size of postscript image - default 7.5 x 10 inches.
  87. X *    -t transx transy = translate image - default 0.5 0.5 inches
  88. X *    -r rotate     = rotate image     - default 0 degress
  89. X *      -l         = landscape (overrides *all* settings.) 
  90. X *    -i         = inverse image - default no inverse 
  91. X *                (Inverse enabled implies white on black.)
  92. X *    -a         = maintain correct aspect ratio - default none.
  93. X *
  94. X */
  95. X
  96. X/* Sun standard raster file format (as obtained by screendump(1)).
  97. X *
  98. X * Header    (8 16-bit quantities)
  99. X * Color Map
  100. X * Image
  101. X *
  102. X */
  103. X
  104. X/* Header Format:
  105. X * 
  106. X * ras_magic        (int)    Raster Magic number 0x59a66a95
  107. X * ras_width        (int)    Width of image in pixels.
  108. X * ras_height        (int)    Height of image in pixels.
  109. X * ras_depth        (int)    Bits per pixel.    Either 1 or 8 bits.
  110. X * ras_length        (int)    Length of image in bytes.
  111. X * ras_type        (int)    Type of file. Assumed to be RT_STANDARD (1) if
  112. X *                produced by a screendump command.
  113. X * ras_maptype        (int)    Type of color map. 
  114. X * ras_maplength    (int)    Length of color map in bytes.
  115. X *
  116. X */
  117. X
  118. X/* Ras_maplength bytes of Color map data. */
  119. X
  120. X/* Ras_length bytes of Image data. */
  121. X
  122. X#include <stdio.h>
  123. X#include <rasterfile.h>
  124. X
  125. X/* Buffer and Input Modes... */
  126. X#define LITERAL    0
  127. X#define COPY    1
  128. X#define IGNORE    2
  129. X
  130. X/* Transmission Variables. */
  131. Xint BufCount;
  132. X
  133. Xunsigned char Buffer[128],
  134. X               CurrByte,
  135. X               NextByte,
  136. X               *BufferP = Buffer;
  137. X
  138. X/* Diagnostic Variables. */
  139. Xint    DiagNLongRuns = 0,
  140. X         DiagMaxRunLength = 0,
  141. X         DiagNumRuns = 0;
  142. Xdouble    DiagSumRunLength = 0;
  143. X
  144. Xmain(argc,argv)
  145. Xint argc;
  146. Xchar **argv;
  147. X{
  148. X     FILE      *fp, *fopen();
  149. X     int     land, inv, aspect;
  150. X     char      *filename;
  151. X     double     sizex, sizey, transx, transy, rotate;
  152. X
  153. X     extern double atof();
  154. X     
  155. X     fp = stdin;
  156. X     aspect = 0;
  157. X     land = 0;
  158. X     filename = "STDIN";
  159. X     sizex = 7.5;
  160. X     sizey = 10.0;
  161. X     transx = transy = 0.5;
  162. X     rotate = 0.0;
  163. X     
  164. X     while(--argc > 0)
  165. X     {
  166. X      ++argv;
  167. X      if((*argv)[0] == '-')
  168. X      {
  169. X           switch((*argv)[1])
  170. X           {
  171. X         case 'l':
  172. X         case 'L':
  173. X            land = 1;
  174. X            break;
  175. X            
  176. X         case 's':
  177. X         case 'S':
  178. X            sizex = atof(*++argv);
  179. X            sizey = atof(*++argv);
  180. X            argc -= 2;
  181. X            break;
  182. X            
  183. X         case 't':
  184. X         case 'T':
  185. X            transx = atof(*++argv);
  186. X            transy = atof(*++argv);
  187. X            argc -= 2;
  188. X            break;
  189. X            
  190. X         case 'r':
  191. X         case 'R':
  192. X            rotate = atof(*++argv);
  193. X            argc--;
  194. X            break;
  195. X            
  196. X         case 'I':
  197. X         case 'i':
  198. X            inv = 1;
  199. X            break;
  200. X            
  201. X         case 'A':
  202. X         case 'a':
  203. X            aspect = 1;
  204. X            break;
  205. X            
  206. X         default:
  207. X            fprintf(stderr,"Illegal switch %c - ignored\n",
  208. X                (*argv)[1]);
  209. X           }
  210. X      }
  211. X      else
  212. X      {
  213. X           if((fp = fopen(*argv, "r")) == (FILE *)NULL)
  214. X           {
  215. X            fprintf(stderr,"Cannot open %s\n",*argv);
  216. X            exit(1);
  217. X           }
  218. X           filename = *argv;
  219. X      }
  220. X     }
  221. X     if (land)
  222. X     {
  223. X      transx = 8.0;
  224. X      transy = 0.5;
  225. X      sizex  = 10.0;
  226. X      sizey  = 7.5;
  227. X      rotate = 90.0;
  228. X     }
  229. X     process(fp, aspect, inv, filename, sizex, sizey, transx, transy, rotate);
  230. X}
  231. X
  232. Xprocess(Fp, aspect, inv, filename, sizex, sizey, transx, transy, rotate)
  233. XFILE *Fp;
  234. Xint inv, aspect;
  235. Xdouble sizex, sizey, transx, transy, rotate;
  236. Xchar *filename;
  237. X{
  238. X     struct rasterfile rh;
  239. X     int i, BS;
  240. X     
  241. X     if (fread((char *) (&rh), sizeof(rh), 1, Fp) != 1)
  242. X     {
  243. X      Error("Can't read rasterfile header\n");
  244. X     }
  245. X
  246. X#ifdef EXTRADIAGS
  247. X     fprintf(stderr, "Ras_width = %d, Ras_height = %d, Ras_depth = %d\n", 
  248. X         rh.ras_width, rh.ras_height, rh.ras_depth);
  249. X     fprintf(stderr, "Ras_length = %d, Ras_type = %d, Ras_maplength = %d\n",
  250. X         rh.ras_length, rh.ras_type, rh.ras_maplength);
  251. X#endif
  252. X     
  253. X     if (rh.ras_magic != RAS_MAGIC)
  254. X     {    
  255. X      Error("Input file is not a Sun Rasterfile!\n");
  256. X     }
  257. X     
  258. X     if (rh.ras_type != RT_STANDARD)
  259. X     {
  260. X      Error("Input file is not in Sun Standard Rasterfile format.\n");
  261. X     }
  262. X     
  263. X     /* Scan off color table */
  264. X     for (i=0; i < rh.ras_maplength; i++)
  265. X     {
  266. X      gb(Fp);
  267. X     }
  268. X     
  269. X     if (aspect)
  270. X     {
  271. X      if ((sizex / rh.ras_width) < (sizey / rh.ras_height))
  272. X      {
  273. X           sizey = sizex * (rh.ras_height * 1.0 / rh.ras_width);
  274. X      }
  275. X      else
  276. X      {
  277. X           sizex = sizey * (rh.ras_width * 1.0 / rh.ras_height);
  278. X      }
  279. X
  280. X     }
  281. X           
  282. X     PrintPostScriptRoutines(rh.ras_height, rh.ras_width, rh.ras_depth,
  283. X                 transx, transy, sizex, sizey, rotate);
  284. X     
  285. X     BS = Encode(Fp, rh.ras_length, inv);
  286. X     
  287. X#ifdef DIAGS
  288. X     fprintf(stderr, "Encoded %d bytes into %d. (Ratio=%d%%)\n",
  289. X         rh.ras_length, BS, 100 - (100 * BS) / rh.ras_length);
  290. X     Diags();
  291. X#endif     
  292. X     fclose(Fp);
  293. X
  294. X     PrintPostScriptClosing();
  295. X}
  296. X     
  297. X/******************************************************************************
  298. X*    I/O Routines.                                  *
  299. X******************************************************************************/
  300. Xint
  301. Xgb(Fp)        /* Get a byte from Fp. */
  302. XFILE *Fp;
  303. X{
  304. X     int byte;
  305. X     
  306. X     if (!feof(Fp))
  307. X      byte = getc(Fp);
  308. X     else
  309. X      Error("Premature EOF.\n");
  310. X     if (ferror(Fp))
  311. X      Error("I/O Error.\n");
  312. X     return(byte);
  313. X}
  314. X
  315. Xint
  316. Xgw(Fp)        /* Get a word (int) from Fp. */
  317. XFILE *Fp;
  318. X{
  319. X     int word;
  320. X     
  321. X     if (!feof(Fp))
  322. X      word = getw(Fp);
  323. X     else
  324. X      Error("Premature EOF.\n");
  325. X     if (ferror(Fp))
  326. X      Error("I/O Error.\n");
  327. X     return(word);
  328. X}
  329. X
  330. XSendHex(Byte)        /* Send a Hex char to Stdout. */
  331. Xunsigned char Byte;
  332. X{
  333. X     static int LineCount = 0;
  334. X
  335. X     printf("%02x",  0xff & Byte);
  336. X     if (++LineCount == 16)
  337. X     {
  338. X      putchar('\n');
  339. X      LineCount = 0;
  340. X     }
  341. X}
  342. X     
  343. Xint
  344. XSendBuffer(Inv)        /* Send a buffer to Stdout. Return BytesSent. */
  345. Xint Inv;
  346. X{
  347. X     int i, BytesSent;
  348. X     
  349. X     if (BufferMode() == LITERAL)
  350. X     {
  351. X      SendHex( (unsigned char) 0xff & BufCount );
  352. X      for (i = 0; i < BufCount+1; i++)
  353. X      {
  354. X           SendHex( (Inv) ? Buffer[i] : ~Buffer[i]);
  355. X      }
  356. X      BytesSent = BufCount+2;
  357. X     }
  358. X     else if (BufferMode() == COPY)
  359. X     {
  360. X      SendHex( (unsigned char) 0xff & (0x100 + BufCount) );
  361. X      SendHex( (Inv) ? Buffer[0] : ~Buffer[0]);
  362. X      BytesSent = 2;
  363. X      DiagRecLRun(mag(BufCount)+1);
  364. X     }
  365. X     return(BytesSent);
  366. X}
  367. X
  368. X/******************************************************************************
  369. X*    Utility Routines.                              *
  370. X******************************************************************************/
  371. Xint
  372. Xmag(Byte)    /* Magitude of a signed char. */
  373. Xint Byte;
  374. X{
  375. X     if (Byte & 0x80)
  376. X     {
  377. X      /* Signed */
  378. X      Byte = ~(--Byte);
  379. X     }
  380. X     return( 0xff & Byte );
  381. X}
  382. X      
  383. X/******************************************************************************
  384. X*    Buffer Management Routines.                          *
  385. X******************************************************************************/
  386. Xint
  387. XInputMode()
  388. X{
  389. X     if (CurrByte == NextByte)
  390. X      return(COPY);
  391. X     return(LITERAL);
  392. X}
  393. X
  394. Xint
  395. XBufferMode()
  396. X{
  397. X     if (BufCount >= 0 && BufCount <= 127)
  398. X      return(LITERAL);
  399. X     else if (BufCount >= -127 && BufCount <= -1)
  400. X      return(COPY);
  401. X     return(IGNORE);
  402. X}
  403. X
  404. XInitLitMode(Fp, NBytes, Inv)
  405. XFILE *Fp;
  406. Xint *NBytes, Inv;
  407. X{
  408. X     BufferP    = Buffer;
  409. X     BufCount   = -1;
  410. X     ContLitMode(Fp, NBytes, Inv);
  411. X}
  412. X
  413. XContLitMode(Fp, NBytes, Inv)
  414. XFILE *Fp;
  415. Xint *NBytes, Inv;
  416. X{
  417. X     if (BufCount == 127)
  418. X     {
  419. X      SendBuffer(Inv);
  420. X      BufferP  = Buffer;
  421. X      BufCount = -1;
  422. X     }
  423. X     *BufferP++ = CurrByte;
  424. X     BufCount++;
  425. X     CurrByte   = NextByte;
  426. X     NextByte   = (unsigned char) gb(Fp);
  427. X     (*NBytes)--;
  428. X}
  429. X     
  430. XInitCopyMode(Fp, NBytes, Inv)
  431. XFILE *Fp;
  432. Xint *NBytes, Inv;
  433. X{
  434. X     BufferP    = Buffer;
  435. X     *BufferP++ = CurrByte;
  436. X     BufCount   = -1;
  437. X     CurrByte   = (unsigned char) gb(Fp);
  438. X     NextByte   = (unsigned char) gb(Fp);
  439. X     *NBytes   -= 2;
  440. X}
  441. X
  442. XContCopyMode(Fp, NBytes, Inv)
  443. XFILE *Fp;
  444. Xint *NBytes, Inv;
  445. X{
  446. X     if (BufCount == -127)
  447. X     {
  448. X      SendBuffer(Inv);
  449. X      InitCopyMode(Fp, NBytes, Inv);
  450. X      DiagNLongRuns++;
  451. X     }
  452. X     BufCount--;
  453. X     CurrByte   = NextByte;
  454. X     NextByte   = gb(Fp);
  455. X     (*NBytes)--;
  456. X}
  457. X
  458. X/******************************************************************************
  459. X*    Encoding Algorithm.                              *
  460. X******************************************************************************/
  461. Xint
  462. XEncode(Fp, NBytes, Inv)
  463. XFILE *Fp;
  464. Xint NBytes, Inv;
  465. X{
  466. X     int BytesSent = 0;
  467. X     
  468. X     /* Initialize Buffer, BufCount, NextByte, CurrByte */
  469. X     CurrByte = (unsigned char) gb(Fp);
  470. X     NextByte = (unsigned char) gb(Fp);
  471. X     if (InputMode() == LITERAL)
  472. X     {
  473. X      InitLitMode(Fp, &NBytes, Inv);
  474. X     }
  475. X     else
  476. X     {
  477. X      InitCopyMode(Fp, &NBytes, Inv);
  478. X     }
  479. X     while (NBytes > 2)
  480. X     {
  481. X      switch(BufferMode())
  482. X      {
  483. X        case LITERAL:
  484. X           if (InputMode() == COPY)
  485. X           {
  486. X            BytesSent += SendBuffer(Inv);
  487. X            InitCopyMode(Fp, &NBytes, Inv);
  488. X           }
  489. X           else
  490. X           {
  491. X            ContLitMode(Fp, &NBytes, Inv);
  492. X           }
  493. X           break;
  494. X        case COPY:
  495. X           if (CurrByte == Buffer[0])
  496. X           {
  497. X            ContCopyMode(Fp, &NBytes, Inv);
  498. X           }
  499. X           else
  500. X           {
  501. X            BytesSent += SendBuffer(Inv);
  502. X            if (InputMode() == COPY)
  503. X            {
  504. X             InitCopyMode(Fp, &NBytes, Inv);
  505. X            }
  506. X            else
  507. X            {
  508. X             InitLitMode(Fp, &NBytes, Inv);
  509. X            }
  510. X           }
  511. X           break;
  512. X        default:
  513. X           Error("Bad Buffer Mode... Sorry\n");
  514. X           break;
  515. X      }
  516. X     }
  517. X     BytesSent += SendBuffer(Inv);
  518. X     /* Send out rem'g 2 bytes in LITERAL mode. */
  519. X     Buffer[0] = CurrByte;
  520. X     Buffer[1] = NextByte;
  521. X     BufCount = 1;
  522. X     BytesSent += SendBuffer(Inv);
  523. X     return(BytesSent);
  524. X}
  525. X
  526. X/******************************************************************************
  527. X*    Diagnostic Routines.                              *
  528. X******************************************************************************/
  529. XDiagRecLRun(Rlength)
  530. Xint Rlength;
  531. X{
  532. X#ifdef DIAGS
  533. X     if (Rlength > DiagMaxRunLength)
  534. X      DiagMaxRunLength = Rlength;
  535. X     DiagSumRunLength += Rlength;
  536. X     DiagNumRuns++;
  537. X#endif
  538. X}
  539. X
  540. XDiags()
  541. X{
  542. X#ifdef DIAGS
  543. X     fprintf(stderr, "Longest Run (<= 128) = %d\n", DiagMaxRunLength);
  544. X     fprintf(stderr, "Number of Runs over 128 = %d\n", DiagNLongRuns);
  545. X     fprintf(stderr, "Average Run Length of %d. (%d Runs)\n",
  546. X         (int) DiagSumRunLength / DiagNumRuns, DiagNumRuns);
  547. X#endif
  548. X}
  549. X
  550. X/******************************************************************************
  551. X*    PostScript Output Routines.                           *
  552. X******************************************************************************/
  553. XPrintPostScriptRoutines(ras_h, ras_w, ras_d, tx, ty, sx, sy, rot)
  554. Xint ras_h, ras_w, ras_d;
  555. Xdouble tx, ty, sx, sy, rot;
  556. X{
  557. X     printf("%%!\n/inch {72 mul} def\n");
  558. X     printf("/bpp %d def\n", ras_d);
  559. X     printf("/scanlines %d def\n", ras_h);
  560. X     printf("/scansize %d def\n", ras_w);
  561. X     printf("/bitmapx\n{");
  562. X     printf(" %d %d %d [%d 0 0 %d 0 %d] ", ras_w, ras_h, ras_d, ras_w, 
  563. X        -ras_h, ras_h);
  564. X     printf("{currentfile readrlehexstring pop } image\n} def\n");
  565. X     printf("gsave\n");
  566. X     printf("%f inch %f inch translate\n",tx, ty);
  567. X     printf("%f rotate\n", rot );
  568. X     printf("%f inch %f inch scale\n", sx, sy);
  569. X     printf("/readrlehexstring\t%% rle_file => decoded_string boolean\n");
  570. X     printf("{\n\t/fileptr exch def\n\tfileptr 1 string readhexstring {");
  571. X     printf("\n\t\t0 get dup 128 and 0 eq\n");
  572. X     printf("\t\t{ 1 add /Buffer exch string def\n");
  573. X     printf("\t\t\tfileptr Buffer readhexstring\n\t\t}\n\t\t{");
  574. X     printf(" 256 exch sub /BufCount exch def\n");
  575. X     printf("\t\t\t/Buffer BufCount 1 add string def\n");
  576. X     printf("\t\t\t/RunInt fileptr 1 string readhexstring");
  577. X     printf(" pop 0 get def\n");
  578. X     printf("\t\t\t0 1 BufCount { RunInt Buffer 3 1 roll put } for\n");
  579. X     printf("\t\t\tBuffer true\n\t\t} ifelse\n\t}\n\t{ false } ifelse\n");
  580. X     printf("} def\n");
  581. X     printf("/clipathx\n{\tnewpath\n\t0 0 moveto\n\t%f inch 0", sx);
  582. X     printf(" lineto\n\t%f inch %f inch lineto\n\t0 %f inch lineto\n",
  583. X        sx, sy, sy);
  584. X     printf("\tclosepath\n} def\nclipathx clip\n");
  585. X     printf("bitmapx\n");
  586. X}
  587. X
  588. XPrintPostScriptClosing()
  589. X{     
  590. X     printf("\ngrestore\n");
  591. X     printf("showpage\n");
  592. X}
  593. X
  594. X/******************************************************************************
  595. X*    Error Routine.                                  *
  596. X******************************************************************************/
  597. XError(S1, S2, S3)
  598. Xchar *S1, *S2, *S3;
  599. X{
  600. X     fprintf(stderr, S1, S2, S3);
  601. X     exit(-1);
  602. X}
  603. SHAR_EOF
  604. if test 12873 -ne "`wc -c 'sun2ps.c'`"
  605. then
  606.     echo shar: error transmitting "'sun2ps.c'" '(should have been 12873 characters)'
  607. fi
  608. echo shar: extracting "'sun2ps.l'" '(3986 characters)'
  609. if test -f 'sun2ps.l'
  610. then
  611.     echo shar: over-writing existing file "'sun2ps.l'"
  612. fi
  613. sed 's/^X//' << \SHAR_EOF > 'sun2ps.l'
  614. X.TH SUN2PS L "" "" "User Contributed Software"
  615. X.SH NAME
  616. Xsun2ps \- a Sun rasterfile to PostScript image filter using run length 
  617. Xencoding
  618. X.SH SYNOPSIS
  619. X.B sun2ps
  620. X[
  621. X.B \-s sizex sizey
  622. X] [ 
  623. X.B \-t transx transy
  624. X] [
  625. X.B \-r rot
  626. X] [
  627. X.B \-i
  628. X] [
  629. X.B \-a
  630. X] [
  631. X.B \-l
  632. X] [ rasfile ]
  633. X.SH OPTIONS
  634. X.TP
  635. X.B \-s
  636. XSet the x and y size of the image to
  637. X.I sizex
  638. Xand
  639. X.I sizey
  640. Xinches, respectively. Defaults to 7.5 x 10 inches.
  641. X.TP
  642. X.B \-t
  643. XTranslate the origin of the x-y axis to 
  644. X.I transx
  645. Xand
  646. X.I transy
  647. Xinches, respectively. Defaults to (0.5, 0.5) inches.
  648. X.TP
  649. X.B \-r 
  650. XRotate the image by
  651. X.I rot
  652. Xdegrees. Note: rotating the image
  653. X.I does not
  654. Xtranslate the x-y origin. When using this option, be sure to translate
  655. Xthe origin accordingly. Default is 0 degrees. See the -l option.
  656. X.TP
  657. X.B \-i
  658. XInvert the image. This implies a white image on a black background.
  659. XDefault is a black image on a white background.
  660. X.TP
  661. X.B \-l
  662. XLandscape mode. This option will override any previous size, translation
  663. Xand rotation settings. Its is intended to provide a quick, landscape
  664. Ximage. Default is off (or portrait mode).
  665. X.TP
  666. X.B \-a
  667. XAutomatically resize the image to conform to its aspect ratio. Normally,
  668. X.I sun2ps
  669. Xwill scale the image to the full page size (or 
  670. X.I sizex
  671. Xand
  672. X.I sizey,
  673. Xif given). Default is off.
  674. X.SH DESCRIPTION
  675. X.sp 1
  676. X.TP
  677. X.B Overview
  678. X.br
  679. X.sp 1
  680. X.I Sun2ps
  681. Xtranslates images stored in Sun Rasterfile format (see
  682. X.I rasterfile(5)
  683. Xfor info on file format) to standard PostScript code. Run length
  684. Xencoding/decoding was also incorporated into 
  685. X.I sun2ps
  686. Xto decrease the size of the text file produced (full sized screendumps
  687. Xproduce a file in excess of 300K, without compression). The specifics
  688. Xof the encoding algorithm are described below. Using this compression,
  689. Xfull screen dumps (using
  690. X.I screendump(1))
  691. Xcan be compressed from 20% to 30% of the original. Unfortunately,
  692. Xdue to the nature of the text file, binary image data is doubled
  693. Xsince each byte is stored as two hex digits. 
  694. X.br
  695. X.TP
  696. X.B Run Length Encoding
  697. X.br
  698. X.sp 1
  699. XThe run length encoding strategy used in
  700. X.I sun2ps
  701. Xis a byte-level scheme that allows runs up to 128. A maximum run length
  702. Xof 128 was chosen so as to conform with images produced by the Degas Elite
  703. Xsystem for the Atari ST. Our intent is to allow for the display of Degas
  704. Ximages on NeWS windows. Using this scheme, image data is sent in two types
  705. Xof packets, or buffers. Along with each buffer is a count, which identifies
  706. Xthe size of the packet and its type. Copy packets, or "runs" in their most
  707. Xconventional sense, consist of a single byte with its count specifying
  708. Xthe number of times this byte is to be repeated. Literal packets consist of
  709. Xa buffer of non-repeated bytes with its count specifying the size of the
  710. Xpacket. A buffer count of 
  711. X.I N
  712. Xindicates:
  713. X.br
  714. X.sp 1
  715. X.I N = 0..127 
  716. X: Literal mode. Send out the next
  717. X.I N
  718. X+ 1 bytes as is.
  719. X.br
  720. X.I N = -1..-127
  721. X: Copy mode. Copy the next byte 
  722. X.I -N
  723. X+ 1 times.
  724. X.br
  725. X.I N = -128
  726. X: Ignore.
  727. X.br
  728. X.TP
  729. X.B Input, Output & Stderr
  730. X.sp 1
  731. X.I Sun2ps
  732. Xsends its PostScript output to stdout. An input rasterfile may be specified
  733. Xon the command line, or if excluded, stdin is used. 
  734. X.I Sun2ps
  735. Xcan be compiled with diagnostic information being reported to stderr.
  736. XDiagnostics include compression ratio, average run length, and number of
  737. Xruns over the maximum. See the Makefile for setting the appropriate
  738. Xflags for the diagnostic output.
  739. X.SH EXAMPLES
  740. X.br
  741. X.sp 1
  742. XStandard usage is:
  743. X.br
  744. X.na
  745. X.sp 1
  746. XMyPrompt% screendump | sun2ps -l | lpr   OR
  747. X.br
  748. X.sp 1
  749. XMyPrompt% screendump | sun2ps -l > screen.ps   OR
  750. X.br
  751. X.sp 1
  752. XMyPrompt% sun2ps -a /u/big/jerk/image.ras > image.ps
  753. X.br
  754. X.ad
  755. X.SH AUTHORS
  756. X.na
  757. XGlenn Boysko    (boysko@mandrill.ces.cwru.edu)
  758. X                ({decvax, sun}!mandrill!boysko)
  759. X.ad
  760. X.br
  761. X.sp 1
  762. XWith references to prior work ("postimage") by:
  763. X.na
  764. X.br
  765. X.sp 1
  766. XJ.R. Bammi      (bammi@mandrill.ces.cwru.edu)
  767. X                ({decvax, sun}!mandrill!bammi)
  768. X.ad
  769. X.SH SEE ALSO
  770. Xscreendump(1), rasterfile(5), rasfilter8to1(1).
  771. X.SH BUGS
  772. XNo Bugs! Just features!
  773. X.SH DATE
  774. X3/25/88
  775. SHAR_EOF
  776. if test 3986 -ne "`wc -c 'sun2ps.l'`"
  777. then
  778.     echo shar: error transmitting "'sun2ps.l'" '(should have been 3986 characters)'
  779. fi
  780. #    End of shell archive
  781. exit 0
  782.